package cn.edu.ujn.booksshop.service;

import static org.junit.Assert.*;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import cn.edu.ujn.booksshop.dao.User;
import cn.edu.ujn.booksshop.dao.UserMapper;
import cn.edu.ujn.util.Page;

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = "classpath:spring-mybatis.xml")
public class IUserServiceTest {

	@Autowired
	private IUserService userService;

	@Autowired
	private User userDao;

	@Autowired
	private UserMapper userMapperDao;
	
	@Test
	public void test() {
		userDao.setUserid(1);
		userDao.setPassword("a");
		User findUser = userService.findUser(userDao);
		System.out.println("findUser:");
		System.out.println(findUser);
	}
	
	@Test
	public void testSellectAll() {
		Page<User> selectAll = this.userService.selectAll(2, 5);
		System.out.println(selectAll);
	}
	
	@Test
	public void testDeleteUser() {
		int deleteByPrimaryKey = this.userMapperDao.deleteByPrimaryKey(11);
		System.out.println("testDeleteUser: ");
		System.out.println(deleteByPrimaryKey);
	}
	@Test
	public void testUpdateUser()
	{
		userDao.setUserid(1);
		userDao.setUsername("bhs");
		int selective = this.userMapperDao.updateByPrimaryKeySelective(userDao);
		System.out.println(selective);
	}

}
